<%@ page contentType="text/html; charset=utf-8" %>
<%@ include file="/WEB-INF/jsp/com/include/declare.jspf" %>
<%@ include file="/WEB-INF/jsp/com/include/doctype.jspf" %>

<script>
function openLayer1(evntMnSn){
    $.ajax({
        type: "GET",
        dataType : "text",
        url: "<c:url value='/evnt/evntWnrLayer.do'/>",
        data: { 
            'evntMnSn' : evntMnSn
        },
        success: function(data){
            if(data){
                $("#layerpopup-winnerpopup").html('');
                $("#layerpopup-winnerpopup").append(data);
                $('body').dimmedFrame();
                $("#winnerpopup").css({top:$(window).scrollTop()+250}).show();
            }
        }
    });
    
}

function closeLayer1(){
    $('.dimmed-frame').remove();
    $("#winnerpopup").hide(); 
}

function checkWinner(evntMnSn){

    var hpNo1 = $("#hpNo1");
    var hpNo2 = $("#hpNo2");
    var hpNo3 = $("#hpNo3");
    var mbrNm = $("#mbrNm");
    
    if(hpNo2.val() == "" || hpNo2.val().length<3){
        alert("전화번호를 입력해 주세요.");
        hpNo2.focus();
        return;
    }
    if(hpNo3.val() == "" || hpNo3.val().length<4){
        alert("전화번호를 입력해 주세요.");
        hpNo3.focus();
        return;
    }
    
    if(mbrNm.val() == ""){
        alert("성명을 입력해 주세요.");
        mbrNm.focus();
        return;
    }
    var ptcChidHpNo = hpNo1.val()+hpNo2.val()+hpNo3.val();
    var ptcChidNm = mbrNm.val();
    
    
    $.ajax({
        type: "POST",
        dataType : "text",
        url: "<c:url value='/evnt/selectEvntWnrDetail.do'/>",
        data: { 
            'evntMnSn' : evntMnSn,
            'ptcChidHpNo' : ptcChidHpNo,
            'ptcChidNm' : ptcChidNm
        },
        success: function(data){
            var result={};
            var items = $(data).find("item");
            items.each(function(index,element){
               var name = $(this).find("name").text();
               var value = $(this).find("value").text();
               result[name] = value;
            });
            if(result["result"] =="OK"){
                $.ajax({
                    type: "POST",
                    dataType : "text",
                    url: "<c:url value='/evnt/evntWnrMemoLayer.do'/>",
                    data: { 
                        'evntMnSn' : evntMnSn,
                        'winCd' : result["value"]
                    },
                    success: function(data){
                        if(data){
                            $("#layerpopup-winnerpopup").html('');
                            $("#layerpopup-winnerpopup").append(data);
                            $('body').dimmedFrame();
                            $("#winnerpopup").hide();
                            $("#layerpopup-winnerpopup2").html('');
                            $("#layerpopup-winnerpopup2").append(data);
                            var wHeight = $(window).height();
                            var divHeight = $("#winnerpopup02").height();
                            if(divHeight > wHeight){
                                $("#winnerpopup02").css({top:$(window).scrollTop()});    
                            }else{
                                $("#winnerpopup02").css({top:$(window).scrollTop()+((wHeight - divHeight) /2)});
                            }
                            
                            $("#winnerpopup02").show();
                        }
                    }
                });
            }else{
                $.ajax({ 
                    type: "POST",
                    dataType : "text",
                    url: "<c:url value='/evnt/evntFailLayer.do'/>",
                    data: { 
                        'evntMnSn' : evntMnSn 
                    },
                    success: function(data){
                        if(data){
                            $("#layerpopup-winnerpopup").html('');
                            $("#layerpopup-winnerpopup").append(data);
                            $('body').dimmedFrame();
                            $("#winnerpopup").hide();
                            $("#layerpopup-winnerpopup2").html('');
                            $("#layerpopup-winnerpopup2").append(data);
                            var wHeight = $(window).height();
                            var divHeight = $("#winnerpopup02").height();
                            if(divHeight > wHeight){
                                $("#winnerpopup02").css({top:$(window).scrollTop()});    
                            }else{
                                $("#winnerpopup02").css({top:$(window).scrollTop()+((wHeight - divHeight) /2)});
                            }                            
                            $("#winnerpopup02").show();
                        }
                    }
                });  
            }
        }
    });
    
}

function evntPrint(id) {
    $('#'+id).printArea({mode: 'popup', popupClose: false});
}

function goView(st, seq){
    if(st=="P"){
        location.href="/kr/evnt/selectEvntMnDetail.do?evntMnSn="+seq;
    }else if(st=="S"){
        location.href="/kr/evnt/selectEvntMnDetailEnd.do?evntMnSn="+seq;
    }
}

</script>
</head>
<body>
<!-- 당첨자 발표 -->
<div id="winnerpopup" class="layerpopup winnerpopup"><div class="layerpopup-inner">
    <div class="layerpopup-head">
        <h1><img src="/kr/images/layerpopup/h1_winner.gif" alt="당첨자 발표" /></h1>
        <p class="desc"><img src="/kr/images/layerpopup/h1_winner_desc.gif" alt="이벤트에 참여해주신 모든 고객님들께 감사 드립니다." /></p>
    </div>
    <div class="layerpopup-contents" id="layerpopup-winnerpopup">
        
    </div>
    <!-- close -->
    <div class="close-area"><div class="close-area-inner">
        <img src="/kr/images/layerpopup/btn_close.gif" alt="닫기" class="close" />
    </div></div>
    <!-- //close -->
</div></div>
<!-- //당첨자 발표 -->

<!-- 당첨자 발표2 -->
<div id="winnerpopup02" class="layerpopup winnerpopup02"><div class="layerpopup-inner">
    <div class="layerpopup-head">
        <h1><img src="/kr/images/layerpopup/h1_winner.gif" alt="당첨자 발표" /></h1>
        <p class="desc"><img src="/kr/images/layerpopup/h1_winner_desc.gif" alt="이벤트에 참여해주신 모든 고객님들께 감사 드립니다." /></p>
    </div>
    <div class="layerpopup-contents" id="layerpopup-winnerpopup2">
        
    </div>
    <!-- close -->
    <div class="close-area"><div class="close-area-inner">
        <img src="/kr/images/layerpopup/btn_close.gif" alt="닫기" class="close" />
    </div></div>
    <!-- //close -->
</div></div>
<!-- //당첨자 발표2 -->


<%@ include file="/WEB-INF/jsp/com/include/layerpopup.jspf" %>
<div id="wrap" class="non-subnavigation">
    <%@ include file="/WEB-INF/jsp/com/include/navi_utill_sub.jspf" %>
    <%@ include file="/WEB-INF/jsp/com/include/navi_header.jspf" %>
    <hr />

    <%@ include file="/WEB-INF/jsp/com/include/sub_header_global03.jspf" %>
    <hr />

	<div id="container">
		<div id="subtitle-area"><div class="subtitle-area-inner">
			<%@ include file="/WEB-INF/jsp/com/include/location.jspf" %>
		</div></div>
		<div id="article">
			<ul class="mypage-navigation">
                <li><a href="<c:url value="/mpg/summeryList.do"/>"><img src="/kr/images/global_menu/navi_mypage01_out.gif" alt="나의 요약정보" /></a></li>
                <li><a href="<c:url value="/mpg/pwdCheckView.do"/>"><img src="/kr/images/global_menu/navi_mypage02_out.gif" alt="회원 정보" /></a></li>
                <li><a href="<c:url value="/mpg/QuotList.do"/>"><img src="/kr/images/global_menu/navi_mypage03_out.gif" alt="최근 견적" /></a></li>
                <li><a href="<c:url value="/mpg/ctlgListPaging.do"/>"><img src="/kr/images/global_menu/navi_mypage04_out.gif" alt="카탈로그 신청 이력" /></a></li>
                <li><a href="<c:url value="/mpg/tdaListPaging.do"/>"><img src="/kr/images/global_menu/navi_mypage05_out.gif" alt="시승 신청 이력" /></a></li>
                <li><a href="<c:url value="/mpg/mpgEvntInfoView.do"/>"><img src="/kr/images/global_menu/navi_mypage06_over.gif" alt="이벤트 참여 이력" /></a></li>
                <li><a href="<c:url value="/mpg/QAListPaging.do"/>"><img src="/kr/images/global_menu/navi_mypage07_out.gif" alt="Q&amp;A" /></a></li>
			</ul>
			<h4 class="subsection"><img src="/kr/images/title/h4_global_menu03_06.gif" alt="이벤트 참여 이력" /></h4>
			<div class="modify-contents-wrap">
				<h5><img src="/kr/images/title/h5_global_menu03_06.gif" alt="이벤트 참여 LIST" /></h5>
				<p><img src="/kr/images/title/h5_global_menu03_06_desc.gif" alt="현대자동차 이벤트 참여 이력은 당첨일 기준 1년간 보관 됩니다." /></p>
              <c:if test="${empty resultList }">
                <div>
                <li >  참여 이력이 없습니다.</li>
                </div>
               </c:if> 
               <c:if test="${not empty resultList }">
               
                    <div class="event-list subsection02">
                    <jsp:useBean id="now" class="java.util.Date"/> 
                    <fmt:formatDate value="${now}" pattern="yyyyMMddHHmm"  var="now0"/>  
                    
                    
                      <c:forEach var="result" items="${resultList}" varStatus="status">
                      <fmt:parseDate value="${result.fnhDt}" pattern="yyyyMMddHHmm" var="now1" /> 
                      <fmt:formatDate value="${now1}" pattern="yyyyMMddHHmm"  var="now2"/> 
                      <div class="section">    
    						<a href="javascript:goView('${result.st}','${result.evntMnSn}')">
                            <img src="<c:url value='${result.thumnImgPath}'/>" alt="${result.evntTitl}" class="thumb" />
                            </a>
    						<ul class="information">
    							<li>
    								<strong class="title"><img src="/kr/images/event/txt_event01_02.gif" alt="제목" /></strong>
    								<p class="subject"><a href="javascript:goView('${result.st}','${result.evntMnSn}">${result.evntTitl}</a></p>
    							</li>
    							<li>
    								<strong class="title"><img src="/kr/images/event/txt_event01_03.gif" alt="내용" /></strong>
    								<p>${result.evntSbc}</p>
    							</li>
    							<li>  
    								<strong class="title"><img src="/kr/images/event/txt_event01_04.gif" alt="기간" /></strong>
                                <p>${fn:substring(result.strtDt, 0, 4)}-${fn:substring(result.strtDt, 4, 6)}-${fn:substring(result.strtDt, 6, 8)} ~ ${fn:substring(result.fnhDt, 0, 4)}-${fn:substring(result.fnhDt, 4, 6)}-${fn:substring(result.fnhDt, 6, 8)}</p>
    							</li>
    							<li>
    								<strong class="title"><img src="/kr/images/event/txt_event01_05.gif" alt="대상" /></strong>
                                     <p><c:if test="${result.evntSubj == 'E1'}">
                                    <able:hmcCodeTag type="codeNm" gCd="EVNTUBJ" comCd="E1"/>
                                    </c:if>
                                    <c:if test="${result.evntSubj == 'E2'}">
                                    <able:hmcCodeTag type="codeNm" gCd="EVNTUBJ" comCd="E2"/>
                                    </c:if></p>
    							</li>
    						</ul> 
                            <c:if test="${result.evntType != 'E4'}">
        		                <c:if test="${result.st == 'P'}">
                                    <c:if test="${now0 > now2}" > 
                                        <img src="/kr/images/common/button/btn_winner_ing.gif" alt="당첨자 선정중" class="winner-btn" />
                                    </c:if> 
                                </c:if>
                                <c:if test="${result.st == 'S'}">
                                    <a href="javascript:openLayer1('${result.evntMnSn}');"><img src="/kr/images/common/button/btn_winner_view.gif" alt="당첨자 보기" class="winner-btn" /></a>
                                </c:if>
                            </c:if>
            			 </div>    
                        <div>
                        </div> 
                       </c:forEach>
    
    				</div>
                 </c:if>
				<div class="btnwrap subsection04" style="display:none">
					<span class="right">
						<a href="#"><img src="/kr/images/common/button/btn_before_join_event.gif" alt="2012. 8월 이전 이벤트 참여 이력보기" /></a>
					</span>
				</div>
			</div>
		</div>
	</div>
	<hr />
    <%@ include file="/WEB-INF/jsp/com/include/footer.jspf" %>